package cn.com.pagoda.ideplugin.common;

/**
 * @author tianmingxing <mx.tian@qq.com> on 2023-05-28
 */
public class StringUtil {

    private StringUtil() {
    }

    /**
     * 将变量名称统一转换成大驼峰格式
     *
     * @param variableName 变量名称
     * @return 大驼峰格式的变量名称
     */
    public static String convertToCamelCase(String variableName) {
        // 将变量名按照指定的分隔符分割成单词数组
        String[] words = variableName.split("[_\\-]");

        // 处理每个单词，将首字母转换为大写
        StringBuilder result = new StringBuilder();
        for (String word : words) {
            if (word.isEmpty()) {
                continue;
            }
            String capitalizedWord = word.substring(0, 1).toUpperCase() + word.substring(1);
            result.append(capitalizedWord);
        }

        return result.toString();
    }
}
